package com.learning.json;

import org.json.JSONArray;
import org.json.JSONObject;

public class JSonParser5 {
	public static void main(String[] args) {
		String src = "{ 'person':[{'name':'Bill' , 'age':25},{'name':'Tom' , 'age':25},{'name':'Bob' , 'age':25}]}";
		try {
			JSONObject object = new JSONObject(src);
			JSONArray array = object.getJSONArray("person");
            p(array.length());
            p(array.get(0));
            p(array.getString(0));
            p(array.getJSONObject(0).getString("name"));
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	static void p(Object o) {
		System.out.println(o);
	}
}
